package net.wang.totakecodenotes.wechatofficaccounts.controller.weixin;

import net.wang.totakecodenotes.wechatofficaccounts.domain.response.ResponseBuilder;
import net.wang.totakecodenotes.wechatofficaccounts.weixin.WeiXinService;
import org.apache.log4j.Logger;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Date;

/**
 *
 */
@RequestMapping(value = "/weixin")
@RestController
public class WeiXinMediaController {
    private static final Logger logger = Logger.getLogger(WeiXinMediaController.class);

    @Resource
    private WeiXinService weiXinService;

    @GetMapping(value = "/downLoad")
    public Object getMediaURL(@RequestParam(value = "media_id") String mediaId,
                              @RequestParam(value = "type", required = false) String type,
                              @RequestParam(value = "created_at", required = false) Date createdAt) throws Exception {

        return ResponseBuilder.build(weiXinService.saveWeiXinMedia(mediaId, type, createdAt));
    }

}
